// 声明promise
function Promise(excutor){
    // 添加初始属性
    this.PromiseState = 'pending'
    this.PromiseResult = null
    // 只有这里的this指向promise，下面声明的resolve（）和reject（）的this指向window
    const self = this
    // 声明resolve()    reject() 函数
    function resolve(data){
        self.PromiseState = 'fullfilled'
        self.PromiseResult = data
    }
    function reject(data){
        self.PromiseState = 'rejected'
        self.PromiseResult = data
    }
    
    try {
        // 同步调用 resolve,reject
        excutor(resolve,reject)
    } catch (error) {
        reject(error)
    }
}

// 为promise添加then方法
Promise.prototype.then = function(onResolved,onRejjected){}
